/* config */
grammar miniSysY;

// 改写为非左递归文法
/* lexer */

Number             : Decimal_const | Octal_const | Hexadecimal_const;
Decimal_const      : Nonzero_digit Digit*;
Octal_const        : '0' Octal_digit*;
Hexadecimal_const  : Hexadecimal_prefix  Hexadecimal_digit+;
Hexadecimal_prefix : '0x' | '0X';
Nonzero_digit      : '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9';
Octal_digit        : '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7';
Digit              : '0' | Nonzero_digit;
Hexadecimal_digit  : '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'
                      | 'a' | 'b' | 'c' | 'd' | 'e' | 'f'
                      | 'A' | 'B' | 'C' | 'D' | 'E' | 'F';
WHITE_SPACE: [ \t\r\n] -> skip;
Annotation1 : '//' .*? ('\n'|'\r\n')   ->skip;
Annotation2 : '/*' (.|'\n'|'/r')*? '*/' ->skip;

/* rules */
compUnit : funcDef;
funcDef  : funcType ident '(' ')' block;
funcType : 'int';
ident    : 'main';
block    : '{' stmt '}';
stmt     : 'return' Number ';';